<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="../public/public.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>管理平台</title>
<meta http-equiv="Content-Type" content="text/html; utf-8">
<script type="text/javascript" src="${ctx}/js/public/html5placeholder.jquery.js"></script>

<script type="text/javascript">
	$(function(){
		document.onkeydown=function(e)
		{
		        if((e ? e.which :event.keyCode)==13)
		        {
		        	toLogin();
		        }
		}
	});
		
	$(function(){
		  $(':input[placeholder]').placeholder();
	});
		
	function toLogin(){
			var userId = $.trim($("#name").val());
			var pwd = $.trim($("#passwd").val());
			var code = $.trim($("#validateCode").val());
			if(userId == ""){
				$("#cname").html("请输入用户名！");
				$("#name").focus();
				return false;
			}else{
				$("#cname").html("");
			}
			if(pwd == ""){
				$("#cpass").html("请输入密码！");
				$("#passwd").focus();
				return false;
			}else{
				$("#cpass").html("");
			}
			if(code == "" || code.length != 4){
				$("#cscode").html("请输入四位验证码！");
				$("#validateCode").focus();
				return false;
			}else{
				$("#cscode").html("");
			}
		    $("#loginForm").submit();
		}
		
	function resetValidateCode(){
		window.frames[0].location.href = window.frames[0].location.href;
	}
</script>
	
</head>
<body>
<form id="loginForm" action="${ctx}/login/userLogin.as"  method="post">
<div>
	<div>
		用户名          
		<input type="text" placeholder="请输入用户名" name="name"  value="${name}" id="name" class="left" style="width:270px;" />
		<span id="cname" style="color:red;"></span>
	</div>
	<div>
		密　码
		<input type="password" placeholder="请输入密码" name="passwd"  value="${passwd}" id="passwd" class="left" style="width:270px;" />
		<span id="cpass" style="color:red;"></span>
	</div>
	<div>
	    <input type="text" placeholder="验证码" class="left" name="validateCode" id="validateCode" style="width:75px;" />
		<iframe style="margin-left:10px;margin-top:6px;float:left;" id="validate"  marginWidth=0 frameborder="0" scrolling="no" src="${ctx}/login/validateCode.as" width="60" height="24" ></iframe>
        <a class="left" style="line-height:30px;cursor:pointer;padding-left:5px;" href="#" onclick="resetValidateCode();">刷新</a>
	    <span id="cscode" style="color:red;"></span>
	</div>
	<div>
		${loginError}
		<button onclick="toLogin();" type="button">登陆</button>
	</div>
</div>
</form>
</body>
</html>